package views.rel;

import java.awt.Dimension;
import java.awt.Image;
import java.awt.event.ActionListener;
import java.awt.event.FocusListener;
import java.awt.event.MouseListener;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.border.EtchedBorder;
import javax.swing.text.MaskFormatter;

import supers.GUIInternalFrame;
import utils.GlobalDeclarations;
import views.SisDskGUI;

@SuppressWarnings("serial")
public class RelDscGUI extends GUIInternalFrame{
	public JFormattedTextField tfDe;
	public JCheckBox cbMen;
	public JCheckBox cbMat;
	public JFormattedTextField tfAte;
	public JButton btListar;
	public JRadioButton rbTodos;
	public JRadioButton rbMot;
	public JFormattedTextField tfCodDsc;
	public JLabel lbDsc;
	public JFormattedTextField tfTxDe;
	public JFormattedTextField tfTxAte;
	
	public RelDscGUI() {
		setTitle("Relat\u00F3rio de Descontos");
		setSize(new Dimension(320, 300));
		
		JPanel panel_1 = new JPanel();
		panel_1.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panel_1.setBounds(10, 116, 283, 66);
		getContentPane().add(panel_1);
		panel_1.setLayout(null);
		
		cbMat = new JCheckBox("Em Matr\u00EDcula");
		cbMat.setSelected(true);
		cbMat.setBounds(6, 7, 93, 23);
		panel_1.add(cbMat);
		
		cbMen = new JCheckBox("Em Mensalidade");
		cbMen.setSelected(true);
		cbMen.setBounds(101, 7, 101, 23);
		panel_1.add(cbMen);
		
		JLabel lblPorcentagem = new JLabel("Porcentagem:");
		lblPorcentagem.setBounds(10, 37, 75, 14);
		panel_1.add(lblPorcentagem);
		
		try {
			tfTxDe = new JFormattedTextField(new MaskFormatter("### %"));
		} catch (ParseException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		tfTxDe.setText("000 %");
		tfTxDe.setColumns(3);
		tfTxDe.setBounds(101, 34, 38, 20);
		panel_1.add(tfTxDe);
		
		try {
			tfTxAte = new JFormattedTextField(new MaskFormatter("### %"));
		} catch (ParseException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		tfTxAte.setText("100 %");
		tfTxAte.setColumns(3);
		tfTxAte.setBounds(170, 34, 38, 20);
		panel_1.add(tfTxAte);
		
		JLabel label_1 = new JLabel("at\u00E9");
		label_1.setBounds(147, 37, 22, 14);
		panel_1.add(label_1);
		
		JLabel lblSituao = new JLabel("Situa\u00E7\u00E3o");
		lblSituao.setBounds(10, 102, 46, 14);
		getContentPane().add(lblSituao);
		
		JLabel lblPeriodo = new JLabel("Periodo");
		lblPeriodo.setBounds(10, 193, 46, 14);
		getContentPane().add(lblPeriodo);
		
		JPanel panel_2 = new JPanel();
		panel_2.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panel_2.setBounds(10, 218, 283, 41);
		getContentPane().add(panel_2);
		panel_2.setLayout(null);
		
		try {
			tfDe = new JFormattedTextField(new MaskFormatter("##/##/####"));
			tfDe.setColumns(10);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		tfDe.setBounds(10, 11, 64, 20);
		panel_2.add(tfDe);
		
		JLabel lblAte = new JLabel("at\u00E9");
		lblAte.setBounds(84, 14, 24, 14);
		panel_2.add(lblAte);
		try {
			tfAte = new JFormattedTextField(new MaskFormatter("##/##/####"));
			tfAte.setColumns(10);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		tfAte.setBounds(109, 11, 64, 20);
		panel_2.add(tfAte);
		
		btListar = new JButton("Listar");
		ImageIcon imageIcon3 = new ImageIcon(SisDskGUI.class.getResource(GlobalDeclarations.ImgBtListar));
		Image img3 = imageIcon3.getImage().getScaledInstance(16, 16, Image.SCALE_SMOOTH);
		btListar.setIcon(new ImageIcon(img3));
		btListar.setBounds(193, 10, 80, 23);
		panel_2.add(btListar);
		
		JPanel panel = new JPanel();
		panel.setLayout(null);
		panel.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
		panel.setBounds(10, 25, 283, 66);
		getContentPane().add(panel);
		
		rbTodos = new JRadioButton("Todos");
		rbTodos.setSelected(true);
		rbTodos.setBounds(6, 7, 55, 23);
		panel.add(rbTodos);
		
		rbMot = new JRadioButton("Por Motivo");
		rbMot.setBounds(6, 33, 96, 23);
		panel.add(rbMot);
		
		try {
			tfCodDsc = new JFormattedTextField(new MaskFormatter("###"));
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		tfCodDsc.setColumns(3);
		tfCodDsc.setBounds(109, 34, 30, 20);
		panel.add(tfCodDsc);
		
		lbDsc = new JLabel(".");
		lbDsc.setBounds(149, 37, 124, 14);
		panel.add(lbDsc);
		
		JLabel label_2 = new JLabel("Aloca\u00E7\u00E3o");
		label_2.setBounds(10, 11, 46, 14);
		getContentPane().add(label_2);
	}

	@Override
	public void setListener(ActionListener ac, FocusListener fl, MouseListener ml) {
		tfCodDsc.addFocusListener(fl);
		rbTodos.addActionListener(ac);
		rbMot.addActionListener(ac);
		cbMat.addActionListener(ac);
		cbMen.addActionListener(ac);
		btListar.addActionListener(ac);
		tfTxDe.addFocusListener(fl);
		tfTxAte.addFocusListener(fl);
	}

	@Override
	public void limpar() {
		tfCodDsc.setText("");
		lbDsc.setText("");
		tfTxDe.setText("000");
		tfTxAte.setText("100");
		tfDe.setText(new SimpleDateFormat("dd/MM/yyyy").format(new Date(System.currentTimeMillis())));
		tfAte.setText(new SimpleDateFormat("dd/MM/yyyy").format(new Date(System.currentTimeMillis())));
	}

	@Override
	public void setDados(Object obj) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Object getDados() {
		// TODO Auto-generated method stub
		return null;
	}
}
